@extends('layouts.default') @section('main')
    <script type="text/javascript" src="/js/jquery.min.js"></script>
    <link rel="stylesheet" href="/css/chosen.css" />
    <script type="text/javascript" src="{{URL::asset('js/')}}/ajaxfileupload.js"></script>
    <script type="text/javascript" src="/js/chosen.jquery.min.js"></script>
    <script type="text/javascript" src="{{URL::asset('js/')}}/common.js"></script>


    <div id="content">
        <div id="content-header">
            <div id="breadcrumb">
                <a href="{{url('home')}}" title="返回首页" class="tip-bottom"><i
                            class="icon-home"></i> 首页</a>
                <a href="#" class="current">短信管理</a>
            </div>
        </div>
        <div class="container-fluid">
            <div class="row-fluid">
                <div class="span9">
                    <div class="widget-box">
                        <div class="widget-title">
						<span class="icon"> <i class="icon-align-justify"></i>
						</span>
                            <h5>短信发送</h5>
                        </div>
                        <div class="widget-content nopadding">
                            <form action="{{url('sms/send')}}" method="post" id="adForm" class="form-horizontal">
                                <div class="control-group ">
                                    <label class="control-label"><span class="redD">*</span>短信模板 :</label>
                                    <div class="controls ">
                                        <select  name="blade" class=" span11" >
                                            <option value="">请选择</option>
                                            @foreach($lists as $k=>$v)
                                            <option value="{{$v->id}}" related_activity="{{$v->related_activity}}" related_project="{{$v->related_project}}">{{$v->subject}}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                </div>

                                <div class="control-group" id="project" style="display: none">
                                    <label class="control-label">项目标题 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="project" placeholder="项目标题" />
                                    </div>
                                </div>

                                <div class="control-group" id="activity" style="display: none">
                                    <label class="control-label">活动标题 :</label>
                                    <div class="controls">
                                        <input type="text" class="span11" name="activity" placeholder="活动标题" />
                                    </div>
                                </div>


                                <div class="control-group ">
                                    <label class="control-label"><span class="redD">*</span>接受者人群 :</label>
                                    <div class="controls ">
                                        <select  name="type" class=" span11" >
                                            <option value="">请选择</option>
                                            <option value="all">全部</option>
                                            <option value="investor">投资人</option>
                                            <option value="projector">项目方</option>
                                            <option value="maker">创客空间</option>
                                            <option value="other">自定义</option>
                                        </select>
                                    </div>
                                </div>

                                <div class="control-group" id="phone" style="display: none">
                                    <label class="control-label">手机号码(可以写多个，以逗号隔开) :</label>
                                    <div class="controls">
                                        <textarea name="phone" style="width:610px; height:100px"></textarea>
                                    </div>
                                </div>

                                <div id="investIndustry"  class="control-group" style="visibility: hidden" >
                                    <label class="control-label"><span class="redD">*</span>主投方向(可以多选) :</label>
                                    <div class="controls">
                                        <select data-placeholder="主投方向(可以多选)" class="chzn-select" name="investIndustry[]" multiple style="width:600px;" tabindex="4" id="dl_chose2">
                                            @foreach($datas as $list)
                                                <option value="{{$list->id}}" >{{$list->name}}</option>
                                            @endforeach
                                        </select>
                                    </div>
                                </div>

                                {{--<div class="control-group">--}}
                                    {{--<label class="control-label">发送原因 :</label>--}}
                                    {{--<div class="controls">--}}
                                        {{--<textarea name="reason" style="width:610px" placeholder="发送原因"></textarea>--}}
                                    {{--</div>--}}
                                {{--</div>--}}

                                <div class="form-actions">
                                    <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                    <button type="button" id="doSave" class="btn btn-success">发送</button>
                                    <button type="reset"  class="btn btn-success">重置</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        $(document).ready(function(){
            //初始化
            $(".chzn-select").chosen();

        });
        $("select[name=blade]").change(function(){
            var related_activity=$(this).find("option:selected").attr('related_activity');
            var related_project=$(this).find("option:selected").attr('related_project');
            if(related_activity==1){
                $("#activity").show();
            }else{
                $("#activity").hide();
            }
            if(related_project==1){
                $("#project").show();
            }else{
                $("#project").hide();
            }

        });


        $("select[name=type]").change(function(){
            var type=$(this).find("option:selected").val();
            if(type=='other'){
                $("#phone").show();
            }else{
                $("#phone").hide();
            }

            if(type=='investor'){
                $("#investIndustry").attr('style',"visibility: visible");
            }else{
                $("#investIndustry").attr('style',"visibility: hidden");
            }

            if(type=='all'){
                alert('确定真的要给全体成员发送短信吗？');
            }
        });

        $("#doSave").click(function(){
            $(this).attr('disabled','disabled');

            ajaxRequest($('#adForm').serializeArray(),$('#adForm').attr('action'),function(data){
                if(data.status){
                    alert(data.message);
                    $("#doSave").removeAttr('disabled');
//                    window.location.href = data.forwardUrl;
                }else{
                    alert(data.message);
                    $("#doSave").removeAttr('disabled');

                }
            });
        });
    </script>
@stop
